//
//  SEGHelpFindViewModel.m
//  Commom
//
//  Created by 梁学彰 on 2020/6/2.
//

#import "SEGHelpFindViewModel.h"

@implementation SEGHelpFindViewModel

- (instancetype)initWithContactName:(NSString *)contactName contactTel:(NSString *)contactTel findContent:(NSString *)findContent {
    if (self = [super init]) {
        [self requestHelpFindWithContactName:contactName contactTel:contactTel findContent:findContent];
    }
    return self;
}

- (void)requestHelpFindWithContactName:(NSString *)contactName contactTel:(NSString *)contactTel findContent:(NSString *)findContent {
    @weakify(self);
    self.signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        [self.requestManager requestHelpFindWithContactName:contactName contactTel:contactTel findContent:findContent finished:^(id result, NSError *error) {
            [subscriber sendNext:error];
            [subscriber sendCompleted];
        }];
        return nil;
    }];
}

#pragma mark - getter
- (SEGHouseRentalAndSaleRequestManager *)requestManager {
    if (!_requestManager) {
        _requestManager = [[SEGHouseRentalAndSaleRequestManager alloc] init];
    }
    return _requestManager;
}
@end
